
public class S2300TelnetTransmissionController {
	
	private String[] FindBoardAndPort(String Port)
	{
		String[] Result = new String[2];
		
		char[] boardPortBuf = new char[Port.length() - Port.lastIndexOf('/')-1]; // Finding the port in string
		Port.getChars(Port.lastIndexOf('/')+1, Port.length(), boardPortBuf, 0); // Writing to buffer Port Info
		
		char[] boardbuf = new char[Port.lastIndexOf('/') - 0]; // Finding board in string
		Port.getChars(0, Port.lastIndexOf('/'), boardbuf, 0);
		
		String portBoard = new String(boardPortBuf);
		String board = new String (boardbuf);
		
		Result[0] = board;
		Result[1] = portBoard;
		
		return Result;
	}
	
	public String[] GetPortStatus(String Port)
	{
		String[] Result = new String[3];
		String[] ParsedBoardAndPort = FindBoardAndPort(Port);
		Result[0] = "screen-length 0 temporary";
		Result[1] = "sys";
		Result[2] = "display interface Ethernet 0/0/" + ParsedBoardAndPort[1];
		return Result;
	}
	
	public String[] SetPortReset(String Port)
	{	
		String[] Result = new String[4];
		String[] ParsedBoardAndPort = FindBoardAndPort(Port);
		Result[0] = "sys";
		Result[1] = "interface Ethernet 0/0/"  + ParsedBoardAndPort[1];
		Result[2] = "shutdown";
		Result[3] = "undo shutdown";
		return Result;
		
	}
	
	public String[] CreateCommand(String[] ParsedCommand)
	{
		if (ParsedCommand[1].contains("GetPortStatus"))return GetPortStatus(ParsedCommand[3]);
		else if (ParsedCommand[1].contains("SetPortReset")) return SetPortReset(ParsedCommand[3]);
		
		return null;
	}
	
	public String ParseReply( String ServerReply)
	{
		return "";
	}
}